<script type="text/javascript" language="javascript">
$(function(){

	$( "#client-dialog-form" ).dialog({
		autoOpen: false,
		maxWidth: 800,
		minWidth: 800,
		width:'auto',
		modal: true,
		buttons: {
			"Save": function() {
				var data=$('#client-form').serialize();
				$.ajax({
					url:'<?=site_url("/backend/ajax/clients/save")?>', 
					data: data,
					dataType: 'json',
					type: 'POST',
					success: function(rData,textStatus,jqXHR) {
						if(rData.status=='success'){
							alert(rData.msg);
							$('#client-dialog-form').dialog('close');
						} else {
							alert("ERROR: \r\n"+rData.msg);
						}
					}
				});
			},
			Cancel: function() {
				$( this ).dialog( "close" );
			}
		},
		close: function() {
			$('#client-form')[0].reset();
			$('#client_act').val("add");
		}
	});

});
</script>
